﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.models {
    import flash.events.*;
    import flash.geom.*;
    import net.wooga.pets.events.*;

    public class Slot {

		[Inject]
        public var eventdispatcher:IEventDispatcher;
        private var m_position:Point;
        private var m_isSlotOccupied:Boolean;// = false
        private var m_floor:int;
        private var m_column:int;
        private var m_id:int;
        private var m_slotMatrix:Array;

        public static const COLUMN_1:uint = 1;
        public static const COLUMN_2:uint = 2;
        public static const COLUMN_3:uint = 3;
        public static const COLUMN_4:uint = 4;
        public static const COLUMN_5:uint = 5;
        public static const COLUMN_6:uint = 6;

        public function Slot(_arg1:Number, _arg2:Number){
            this.position = new Point(_arg1, _arg2);
        }
        public function set position(_arg1:Point):void{
            this.m_position = _arg1;
        }
        public function get position():Point{
            return (this.m_position);
        }
        public function setOccupied():void{
            this.m_isSlotOccupied = true;
            this.eventdispatcher.dispatchEvent(new RoomSlotEvent(RoomSlotEvent.SLOT_IS_OCCUPIED, this.id));
        }
        public function isFree():Boolean{
            return (!(this.m_isSlotOccupied));
        }
        public function isOccupied():Boolean{
            return (this.m_isSlotOccupied);
        }
        public function get floor():int{
            return (this.m_floor);
        }
        public function set floor(_arg1:int):void{
            this.m_floor = _arg1;
        }
        public function set column(_arg1:int):void{
            this.m_column = _arg1;
        }
        public function get column():int{
            return (this.m_column);
        }
        public function get id():int{
            return (this.m_id);
        }
        public function set id(_arg1:int):void{
            this.m_id = _arg1;
        }
        public function isWaitingSlot():Boolean{
            return ((this.id == 0));
        }
        public function isLeavingSlot():Boolean{
            return ((this.id == 5));
        }
        public function isWaitingOrLeavingSlot():Boolean{
            return (((this.isLeavingSlot()) || (this.isWaitingSlot())));
        }
        public function isSlotColumnInBuildingRange():Boolean{
            return ((((((((this.m_column == COLUMN_2)) || ((this.m_column == COLUMN_3)))) || ((this.m_column == COLUMN_4)))) || ((this.m_column == COLUMN_5))));
        }
        public function set slotMatrix(_arg1:Array):void{
            this.m_slotMatrix = _arg1;
        }
        public function hasLeftOccupiedNeighbor():Boolean{
            if (this.column <= Slot.COLUMN_2){
                return (false);
            };
            var _local1:Slot = this.m_slotMatrix[(this.id - 1)];
            return (_local1.isOccupied());
        }
        public function hasRightOccupiedNeighbor():Boolean{
            if (this.column >= Slot.COLUMN_5){
                return (false);
            };
            var _local1:Slot = this.m_slotMatrix[(this.id + 1)];
            return (_local1.isOccupied());
        }
        public function hasTopOccupiedNeighbor():Boolean{
            var _local1:Slot = this.m_slotMatrix[(this.id + 6)];
            return (_local1.isOccupied());
        }
        public function hasBottomOccupiedNeighbor():Boolean{
            var _local1:Slot;
            if (this.m_slotMatrix[(this.id - 6)]){
                _local1 = this.m_slotMatrix[(this.id - 6)];
                return (_local1.isOccupied());
            };
            return (false);
        }
        public function getTopNeighbor():Slot{
            var _local1:Slot = this.m_slotMatrix[(this.id + 6)];
            return (_local1);
        }
        public function getRightNeighbor():Slot{
            var _local1:Slot = this.m_slotMatrix[(this.id + 1)];
            return (_local1);
        }
        public function getBottomNeighbor():Slot{
            var _local1:Slot = this.m_slotMatrix[(this.id - 6)];
            return (_local1);
        }
        public function getLeftNeighbor():Slot{
            var _local1:Slot = this.m_slotMatrix[(this.id - 1)];
            return (_local1);
        }

    }
}//package net.wooga.pets.models 
